import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { BaseItem } from "../common/BaseItem";
import { DropItemData } from "./DropItemData";
import { ItemsUtil } from "../shortcuts/item/ItemsUtil";
import { MoneyUtil } from "../common/util/MoneyUtil";
import { ColorConfig } from "../../resource/ColorConfig";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
//class DropItemRenderer
    
    export  class DropItemRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ configUI(): void
        {
            var loc1=GlobalClass.getBitmap("PackItemBg");
            loc1.width = 38;
            loc1.height = 38;
            loc1.y = 0;
            loc1.x = 0;
            this.addChild(loc1);
            var loc2=ResouceConst.getScaleBitmap("WindowCenterB");
            loc2.setSize(185, 38);
            this.addChild(loc2);
            this._itemText = new GTextFiled();
            this._itemText.width = 100;
            this._itemText.height = 20;
            this._itemText.x = 40;
            this._itemText.y = 9;
            this._itemText.textColor = 11661311;
            this._itemText.selectable = false;
            this._itemText.mouseEnabled = false;
            this.addChild(this._itemText);
            this._pic = new BaseItem();
            this._pic.setSize(35, 35);
            this._pic.move(2, 2);
            this._pic.isDragAble = false;
            this._pic.isDropAble = false;
            this.addChild(this._pic);
            this.mouseChildren = false;
            this.buttonMode = true;
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=null;
            super.data = arg1;
            this._itemData = arg1 as DropItemData;
            if (this._itemData && this._itemData.itemInfo) 
            {
                this._pic.itemData = this._itemData;
                loc1 = this._itemData.itemInfo.item.name;
                if (ItemsUtil.isCoinBindSundry(this._itemData)) 
                {
                    loc1 = MoneyUtil.getMoneyName(this._itemData.itemInfo.item.sellUnit) + "  " + this._itemData.itemInfo.item.sellPrice;
                    this._pic.source = ItemsUtil.CoinIcoUrl;
                    this._pic.mouseEnabled = false;
                    this._pic.mouseChildren = false;
                }
                else 
                {
                    this._pic.mouseChildren = true;
                    this._pic.mouseEnabled = true;
                }
                loc2 = ColorConfig.instance.getItemColor(this._itemData.itemInfo.item.color);
                this._itemText.htmlText = HTMLUtil.addColor(loc1, loc2.color);
            }
            else 
            {
                this._pic.itemData = null;
                this._itemText.text = "";
            }
            return;
        }

        /* internal */ /* var */_pic: BaseItem;

        /* internal */ /* var */_itemText: GTextFiled;

        /* internal */ /* var */_itemData: DropItemData;
    }
